#include<stdio.h>
int main()
{
    int jianb = 0;
    int yinb = 0;
    int n = 0;
    int i = 0;
    scanf("%d %d", &jianb, &yinb);
    getchar();
    scanf("%d", &n);
    getchar();
    int jianb_tmp = jianb;
    int yinb_tmp = yinb;
    int jiashout = 0;
    int yishout = 0;
    int jiagive = 0;
    int yigive = 0;
    int shoutsum = 0;
    int j = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &jiashout, &jiagive, &yishout, &yigive);
        getchar();
        shoutsum = jiashout + yishout;
        if (shoutsum == jiagive && shoutsum == yigive)
        {
            continue;
        }
        if (shoutsum == jiagive)
        {
            jianb_tmp--;
        }
        if (shoutsum == yigive)
        {
            yinb_tmp--;
        }
        if (jianb_tmp < 0 || yinb_tmp < 0)
        {
            for (j = i+1; j < n; j++)
            {
                while(getchar()!='\n')
                {
                    ;
                }
            }
            break;
        }
    }
    if (jianb_tmp < 0)
    {
        printf("A\n%d", yinb - yinb_tmp);
    }
    else
    {
        printf("B\n%d", jianb - jianb_tmp);
    }
    return 0;
}